
function gotoBooking(f,supplier,formId, paramInputId, submitUrl){
	if(f==null || f==undefined || typeof f != 'object'){
		alert("请选择要预定的航班！");
		return;
	}

	if(f.segments.length == 2){
		var b = {
			    "pltmOrder": {
			    	"supplier": supplier,
			        "luggageInfo": "",
			        "purchQuantity": 0,
			        "travelDays": "",
			        "unitPrice": f.fare.adultPrice,//单价
                    "infantTFC": f.fare.infantTFC,//add
                    "seatClass": f.fare.seatClass,//add
                    "adultPrice": f.fare.adultPrice,//add
                    "adultTFC": f.fare.adultTFC,//add
                    "confirmDay": f.fare.confirmDay,//add
                    "chosenBaseFare": JSON.stringify(f.fare.chosenBaseFare).replace(new RegExp('(["\"])', 'g'),"\\\""),//JSON.stringify(f.fare.chosenBaseFare),//add
                    "childPrice": f.fare.childPrice,//add
                    "childTFC": f.fare.childTFC,//add
                    "infantPrice": f.fare.infantPrice, //add
                    "productCode": f.fare.productCode,//add
                    "toStartAirport": f.segments[0].depAp,
			        "toEndAirport": f.segments[0].arrAp,
			        "toStartDate": f.segments[0].depDate,
			        "pssRoutingFareId": "",//待定
			        "from": f.segments[0].depApCn+"（"+f.segments[0].arrAp+"）",
			        "to": f.segments[0].arrApCn+"（"+f.segments[0].arrAp+"）",
			        "ticketLoss":0,
		            "ticketRate":0,
			        "productId":"",//待定
			        "routingType":"ROUND"//待定
			    },
			    "airlineId":"",//待定
			    "pltmOrderFlights": [
		 	        {
			            "arrivalCity": f.segments[0].arrApCn,
			            "arrivalTerminal": f.segments[0].arrTerminal,
			            "arrivalTime": f.segments[0].arrTime,
			            "cabin": f.segments[0].cabinCode,
			            "departureCity": f.segments[0].depApCn,
			            "departureDate": f.segments[0].depDate,
			            "departureTerminal": f.segments[0].depTerminal,
			            "departureTime": f.segments[0].depTime,
			            "flightId": f.segments[0].segmentId,//delete
			            "flightNumber": f.segments[0].flightNo,
			            "flightSegment": 1,
			            "intervalDay": "",
			            "departureCode": f.segments[0].depAp,
			            "arrivalCode": f.segments[0].arrAp,
			            "cabinName":"",
                        "subPrdId":f.segments[0].subPrdId,//add
                        "stopoverInfo":JSON.stringify(f.segments[0].stopover).replace(new RegExp('(["\"])', 'g'),"\\\"")//add
			        },
			        {
                        "arrivalCity": f.segments[1].arrApCn,
                        "arrivalTerminal": f.segments[1].arrTerminal,
                        "arrivalTime": f.segments[1].arrTime,
                        "cabin": f.segments[1].cabinCode,
                        "departureCity": f.segments[1].depApCn,
                        "departureDate": f.segments[1].depDate,
                        "departureTerminal": f.segments[1].depTerminal,
                        "departureTime": f.segments[1].depTime,
                        "flightId": f.segments[1].segmentId,//delete
                        "flightNumber": f.segments[1].flightNo,
                        "flightSegment": 2 ,
                        "intervalDay": "",
                        "departureCode": f.segments[1].depAp,
                        "arrivalCode": f.segments[1].arrAp,
                        "cabinName":"",
                        "subPrdId":f.segments[1].subPrdId,
                        "stopoverInfo":JSON.stringify(f.segments[1].stopover).replace(new RegExp('(["\"])', 'g'),"\\\"")
			        }
			    ],
			    "pltmOrderPassengerList":[]
			};
			$("#"+paramInputId).val(JSON.stringify(b));
	}else{
		var b = {
			    "pltmOrder": {
                    "supplier": supplier,
                    "luggageInfo": "",
                    "purchQuantity": 0,
                    "travelDays": "",
                    "unitPrice": f.fare.adultPrice,//单价
                    "infantTFC": f.fare.infantTFC,//add
                    "seatClass": f.fare.seatClass,//add
                    "adultPrice": f.fare.adultPrice,//add
                    "adultTFC": f.fare.adultTFC,//add
                    "confirmDay": f.fare.confirmDay,//add
                    "chosenBaseFare": JSON.stringify(f.fare.chosenBaseFare).replace(new RegExp('(["\"])', 'g'),"\\\""),//add
                    "childPrice": f.fare.childPrice,//add
                    "childTFC": f.fare.childTFC,//add
                    "infantPrice": f.fare.infantPrice, //add
                    "productCode": f.fare.productCode,//add
                    "toStartAirport": f.segments[0].depAp,
                    "toEndAirport": f.segments[0].arrAp,
                    "toStartDate": f.segments[0].depDate,
                    "pssRoutingFareId": "",//待定
                    "from": f.segments[0].depApCn+"（"+f.segments[0].arrAp+"）",
                    "to": f.segments[0].arrApCn+"（"+f.segments[0].arrAp+"）",
                    "ticketLoss":0,
                    "ticketRate":0,
                    "productId":"",//待定
                    "routingType":"TO"//待定
			    },
			    "airlineId":"",
			    "pltmOrderFlights": [
		 	        {
                        "arrivalCity": f.segments[0].arrApCn,
                        "arrivalTerminal": f.segments[0].arrTerminal,
                        "arrivalTime": f.segments[0].arrTime,
                        "cabin": f.segments[0].cabinCode,
                        "departureCity": f.segments[0].depApCn,
                        "departureDate": f.segments[0].depDate,
                        "departureTerminal": f.segments[0].depTerminal,
                        "departureTime": f.segments[0].depTime,
                        "flightId": f.segments[0].segmentId,//delete
                        "flightNumber": f.segments[0].flightNo,
                        "flightSegment": 1,
                        "intervalDay": "",
                        "departureCode": f.segments[0].depAp,
                        "arrivalCode": f.segments[0].arrAp,
                        "cabinName":"",
                        "subPrdId":f.segments[0].subPrdId,
                        "stopoverInfo":JSON.stringify(f.segments[0].stopover).replace(new RegExp('(["\"])', 'g'),"\\\"")
			        }
			    ],
			    "pltmOrderPassengerList":[]
			};
			$("#"+paramInputId).val(JSON.stringify(b));
	}
	$("#"+formId).attr("action", submitUrl).submit();
}

function gotoContractBooking(datas,supplier,formId, paramInputId, submitUrl){
	if(datas==null || datas==undefined || typeof datas != 'object'){
		alert("请选择要预定的航班！");
		return;
	}
	var flights = [];
	$.each(datas, function(n, f){
        var b = {
            "pltmOrder": {
                "supplier": supplier,
                "luggageInfo": "",
                "purchQuantity": 0,
                "travelDays": "",
                "unitPrice": f.fare.adultPrice,//单价
                "infantTFC": f.fare.infantTFC,//add
                "seatClass": f.fare.seatClass,//add
                "adultPrice": f.fare.adultPrice,//add
                "adultTFC": f.fare.adultTFC,//add
                "confirmDay": f.fare.confirmDay,//add
                "chosenBaseFare": JSON.stringify(f.fare.chosenBaseFare).replace(new RegExp('(["\"])', 'g'), "\\\""),//JSON.stringify(f.fare.chosenBaseFare),//add
                "childPrice": f.fare.childPrice,//add
                "childTFC": f.fare.childTFC,//add
                "infantPrice": f.fare.infantPrice, //add
                "productCode": f.fare.productCode,//add
                "toStartAirport": f.segments[0].depAp,
                "toEndAirport": f.segments[0].arrAp,
                "toStartDate": f.segments[0].depDate,
                "pssRoutingFareId": "",//待定
                "from": f.segments[0].depApCn + "（" + f.segments[0].arrAp + "）",
                "to": f.segments[0].arrApCn + "（" + f.segments[0].arrAp + "）",
                "ticketLoss": 0,
                "ticketRate": 0,
                "productId": "",//待定
                "routingType": "ROUND"//待定
            },
            "airlineId": "",//待定
            "pltmOrderFlights": [
                {
                    "arrivalCity": f.segments[0].arrApCn,
                    "arrivalTerminal": f.segments[0].arrTerminal,
                    "arrivalTime": f.segments[0].arrTime,
                    "cabin": f.segments[0].cabinCode,
                    "departureCity": f.segments[0].depApCn,
                    "departureDate": f.segments[0].depDate,
                    "departureTerminal": f.segments[0].depTerminal,
                    "departureTime": f.segments[0].depTime,
                    "flightId": f.segments[0].segmentId,//delete
                    "flightNumber": f.segments[0].flightNo,
                    "flightSegment": 1,
                    "intervalDay": "",
                    "departureCode": f.segments[0].depAp,
                    "arrivalCode": f.segments[0].arrAp,
                    "cabinName": "",
                    "subPrdId": f.segments[0].subPrdId,//add
                    "stopoverInfo": JSON.stringify(f.segments[0].stopover).replace(new RegExp('(["\"])', 'g'), "\\\"")//add
                },
                {
                    "arrivalCity": f.segments[1].arrApCn,
                    "arrivalTerminal": f.segments[1].arrTerminal,
                    "arrivalTime": f.segments[1].arrTime,
                    "cabin": f.segments[1].cabinCode,
                    "departureCity": f.segments[1].depApCn,
                    "departureDate": f.segments[1].depDate,
                    "departureTerminal": f.segments[1].depTerminal,
                    "departureTime": f.segments[1].depTime,
                    "flightId": f.segments[1].segmentId,//delete
                    "flightNumber": f.segments[1].flightNo,
                    "flightSegment": 2,
                    "intervalDay": "",
                    "departureCode": f.segments[1].depAp,
                    "arrivalCode": f.segments[1].arrAp,
                    "cabinName": "",
                    "subPrdId": f.segments[1].subPrdId,
                    "stopoverInfo": JSON.stringify(f.segments[1].stopover).replace(new RegExp('(["\"])', 'g'), "\\\"")
                }
            ]
        }
		flights.push(b); 
	});
	
	$("#"+paramInputId).val(JSON.stringify(flights));
	$("#"+formId).attr("action", submitUrl).submit();
}
